home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / u_chk.arc / USERIS.PAS < prev    next >
Pascal/Delphi Source File  |  1989-12-17  |  6KB  |  261 lines

  1. Program USERIS;
  2.  
  3. {
  4.  
  5.  John T. McCann, NOVUSER Wizard SysOp, 70007,3430
  6.  1/5/89
  7.  
  8.  Written in Turbo Pascal v5.0
  9.  
  10.  This program will, given a command line argument, verify a user's
  11.  login name on the current file server, ex:
  12.  
  13.  USERIS JOHN
  14.  
  15.  if JOHN is a valid LOGIN NAME (for a user) on the current file server
  16.  a DOS ERRORLEVEL of 0 is returned
  17.  
  18.  if not valid, a DOS ERRORLEVEL of 1 is returned
  19.  
  20.  if no command line arguement is entered 2 is returned
  21.  
  22.  if not logged into any file servers (but the shell is loaded)
  23.  3 is returned
  24.  
  25.  if the shell is not loaded 4 is returned
  26.  
  27. }
  28.  
  29. Uses Crt, Dos;
  30.  
  31. Const
  32.  
  33.   inc = 'UserIs, (c)1989 Wizard Stuff';
  34.   Version = 1.0;
  35.  
  36. Type
  37.  
  38. HalfRegtype = record
  39.                 Al,Ah,Bl,Bh,Cl,Ch,Dl,Dh:byte
  40.               end;
  41.  
  42.  
  43. longs    = record
  44.              ah,al,bh,bl:byte;
  45.            end;
  46.  
  47. MyWord   = record
  48.              wh,wl : byte;
  49.            end;
  50.  
  51. e336cl   = record
  52.              Native : MyWord;
  53.              Func   : Byte;   { $36 for get object name }
  54.              unique : Longs;  { Unique ID for the object }
  55.              end;
  56.  
  57. e336rp   = record
  58.              Native : MyWord;
  59.              id     : longs;     { same id as above }
  60.              ObjTyp : Myword;    { type of object   }
  61.              Name   : array [1..48] of byte;
  62.             end;
  63.  
  64. chkcall   =  record
  65.               Native: MyWord;
  66.               Func  : Byte;  { $46 = get my bindery access level}
  67.              end;
  68.  
  69. chkrply   =  record
  70.               Native: MyWord;
  71.               Mask  : Byte;
  72.               id    : Longs;
  73.              end;
  74.  
  75. E33dcall   = record
  76.               Native: MyWord;
  77.               Func  : Byte;   { 55 for Search for Users }
  78.               Last  : Longs;  { make it -1 }
  79.               ObjTyp: MyWord; { Search for users 0001 }
  80.               ObjNml: Byte;   { 1 }
  81.               ObjNme: array[1..48] of Byte;   { *, if search all is used }
  82.              end;
  83.  
  84. E33drply   = record
  85.               Native    : MyWord;
  86.               Id        : Longs;
  87.               ObjectType: MyWord;
  88.               PropName  : array [1..48] of Byte;
  89.               { could add some space down here since I tell it the reply buffer
  90.                 is 255 bytes long, but, that really isn't going to happen...}
  91.              end;
  92.  
  93. Var
  94. Regs   :  Registers;
  95. hr     :  HalfRegType absolute Regs;
  96.  
  97. cc     : chkcall;
  98. cr     : chkrply;
  99. nc     : e336cl;
  100. nr     : e336rp;
  101. pc     : e33dcall;
  102. pr     : e33drply;
  103. a      : Integer;
  104.  
  105.  
  106. Procedure UserI;
  107. var
  108. PS      : String[80]; { just a string to hold the paramstr(1) variable }
  109.  
  110. Begin
  111.  
  112.  
  113.  
  114. /* NOTE I had used 1f on next line (last.ah), it is now ff, it is SUPPOSE to be ff, sorry
  115.    for any inconvenience this may cause, if you use 1f it will be a problem
  116.    with netware 386 */
  117.  
  118.  
  119. with pc do
  120.   begin
  121.     last.ah:=$ff; { set the last object seen to -1 }
  122.     last.al:=$ff;
  123.     last.bh:=$ff;
  124.     last.bl:=$ff;
  125.   end;
  126.  
  127.   pr.Native.wl:=$00;
  128.   pr.Native.wh:=$FF; { set up reply buffer size, note it really isn't 255
  129.                        bytes long, but neither is the possible reply...}
  130.  
  131.   pc.Native.wl:= $00;
  132.   pc.Native.wh:= $8+length(paramstr(1)); { set up length of request buffer }
  133.  
  134.   pc.Func     := $37; { scan bindery objects }
  135.  
  136.   pc.ObjTyp.wh:= 0;
  137.   pc.ObjTyp.wl:= 1; { 01 = user object type }
  138.  
  139.   pc.ObjNml   := length(paramstr(1));
  140.  
  141.   PS:=paramstr(1);
  142.   for a:=1 to (pc.ObjNml mod 48) do
  143.    begin
  144.     if ord(PS[a]) in [97..122] then PS[a]:=chr(ord(PS[a])-32); {convert to Upper Case}
  145.     pc.ObjNme[a]:=ord(PS[a]);
  146.    end;
  147.  
  148.  
  149.   Regs.Ax:=$E300;
  150.  
  151.   Regs.Es:=Seg(Pr);
  152.   Regs.Di:=Ofs(Pr);
  153.  
  154.   Regs.Ds:=Seg(Pc);
  155.   Regs.Si:=Ofs(Pc);
  156.  
  157.   MsDos(Regs);
  158.  
  159.   if hr.al=0 then halt(0) else halt(1);
  160.  
  161.  
  162. End; { of Proc UserI }
  163.  
  164.  
  165.  
  166. Procedure Will_It_Run;
  167. Begin
  168.  
  169.   TextColor(7);
  170.  
  171.  
  172.     Regs.Ax:=$E300;
  173.  
  174.     cc.Native.wl:=$00;
  175.     cc.Native.wh:=$01;
  176.     cr.Native.wl:=$00;
  177.     cr.Native.wh:=$ff;
  178.     cc.Func     :=$46;
  179.     cr.Mask     :=$00;
  180.     cr.id.al    :=$00;
  181.     cr.id.ah    :=$00;
  182.     cr.id.bl    :=$00;
  183.     cr.id.bh    :=$00;
  184.  
  185.     Regs.Es:=Seg(cr);
  186.     Regs.Di:=Ofs(cr);
  187.  
  188.     Regs.Ds:=Seg(cc);
  189.     Regs.Si:=Ofs(cc);
  190.  
  191.  
  192.   MsDos(Regs);
  193.  
  194.     If (cr.id.al=$00) and
  195.        (cr.id.ah=$00) and
  196.        (cr.id.bl=$00) and
  197.        (cr.id.bh=$00)
  198.  then
  199.     Begin
  200.        TextColor(1);TextBackGround(3);ClrEol;
  201.        Writeln(inc);
  202.        ClrEol;
  203.        Writeln('This utility requires Advanced Netware to run.');
  204.        TextColor(7);TextBackGround(0);ClrEol;
  205.        Halt(4);
  206.     End;
  207.  
  208.   Regs.Ax:=$E300;
  209.   nr.Native.wl:=$00;
  210.   nr.Native.wh:=$FF;
  211.  
  212.   nc.Native.wl:=$00;
  213.   nc.Native.wh:=$05;
  214.  
  215.   Regs.Es:=Seg(nr);
  216.   Regs.Di:=Ofs(nr);
  217.  
  218.   Regs.Ds:=Seg(nc);
  219.   Regs.Si:=Ofs(nc);
  220.  
  221.   nc.func:=$36;
  222.   nc.unique.ah:=cr.id.ah;
  223.   nc.unique.al:=cr.id.al;
  224.   nc.unique.bh:=cr.id.bh;
  225.   nc.unique.bl:=cr.id.bl;
  226.  
  227.   MsDos(Regs);
  228.  
  229.   if hr.al <> 0 then
  230.    Begin
  231.      TextColor(1);TextBackGround(3);ClrEol;
  232.      Writeln(inc);
  233.      ClrEol;
  234.      Writeln('This utility requires you to be logged into the network to run.');
  235.      TextColor(7);TextBackGround(0);ClrEol;
  236.      Halt(3);
  237.    End;
  238.  
  239.  
  240. End; { of Will_it_Run }
  241.  
  242.  
  243. Begin
  244.  
  245. If length(Paramstr(1)) <1 then
  246.  begin
  247.    TextColor(1);TextBackGround(3);ClrEol;
  248.    writeln(inc);
  249.    ClrEol;
  250.    writeln('Usage: USERIS xxxxx  where xxxxx is the username to check');
  251.    writeln('       existence of on the current file server');
  252.    TextColor(7);TextBackGround(0);ClrEol;
  253.    halt(2);
  254.  end;
  255.  
  256.  Will_It_Run;
  257.  
  258.  UserI;
  259.  
  260. End.
  261.